def list_test():
    # 增加
    list_1 = [1, 2, 3, 4, 5]
    list_2 = ['a', 'b', 'c', 'd', 'e']
    list_1 += list_2
    a = ['a']
    list_3 = [a] * 3
    print(list_3)
    a[0] = 'x'
    print(list_3)
    list_1.append("xxxxxxx")
    print(list_1)
    list_1.insert(4, "KK")
    print(list_1)

    # 检索
    print(list_1[3])
    print(list_1[1:5])
    print(list_1.index('a'))

    # 更新
    list_1[0] = "A"
    list_1[1:3] = ["B", "C"]
    print(list_1)

    # 删除
    list_1.pop()
    list_1.remove('a')
    print(list_1)


def tuple_test():
    tuple_1 = (1, 2, 3, 4, 5, 6, 7, 8, 9)
    print(tuple_1[1:3])
    print(tuple_1.index(1))


def dict_test():
    # 增加
    dict_1 = {"a": 1}
    dict_1["b"] = 2
    dict_2 = {"c": 3, "d": 4}
    dict_1.update(dict_2)
    dict_1.setdefault("f", 5)
    print(dict_1)

    # 检索
    print(dict_1["a"])
    print(dict_1.get("g", 22))
    print(dict_1.keys())
    print(dict_1.values())
    print(dict_1.items())

    # 更新
    dict_1["a"] = 56
    dict_1.update({"x": 12, "y": 13, "z": 14})
    print(dict_1)

    # 删除
    dict_1.pop("a")
    dict_1.popitem()
    print(dict_1)


def set_test():
    #增加检索
    set_1 = {"a", "b"}
    set_2 = {"c", "d"}
    set_1.add(1)
    print(set_1)
    print("a" in set_1)

    #更新删除
    set_1.update(set_2)
    set_3 = set_1.union(set_2)
    print(set_1)
    print(set_3)
    set_3.remove("a")
    set_3.pop()
    print(set_3)




if __name__ == "__main__":
    list_test()
    tuple_test()
    dict_test()
    set_test()
